﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BUS;
using DTO;
namespace QLVeChuyenBay
{
    public partial class frmDangNhap : Form
    {
        public frmDangNhap()
        {
            InitializeComponent();
        }
        private void frmDangNhap_Load(object sender, EventArgs e)
        {
            lbl.Text = "";
        }
        private void btnLogin_Click(object sender, EventArgs e)
        {
            DangNhapBUS obj = new DangNhapBUS();
            string Quyen = "";
            if (chkGiamDoc.Checked)
                Quyen = "Giám Đốc";
            else
                Quyen = "Nhân viên";
            if (obj.KTDangNhap(txtUser.Text, txtPass.Text, Quyen))
            {
                if (chkGiamDoc.Checked)
                {

                    frmManHinhChinh frm = (frmManHinhChinh)this.MdiParent;
                    frm.QuyenGiamDoc(true, false);
                    this.Close();

                }
                else
                {
                    frmManHinhChinh frm = (frmManHinhChinh)this.MdiParent;
                    frm.QuyenNhanVien(true, false);
                    this.Close();
                }

            }
            else
            {
                lbl.Text = "Tên người dùng hoặc mật khẩu không đúng!";
               
            }
        }

        private void btnHuy_Click(object sender, EventArgs e)
        {
            this.Close();
        }

       
        private void txtPass_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                btnLogin_Click(null, null);
        }
        private void chkGiamDoc_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                btnLogin_Click(null, null);
        }
        

       
    }
}
